/**
 * Copyright (c) 2022 Beijing Jiaotong University
 * PhotLab is licensed under [Open Source License].
 * You can use this software according to the terms and conditions of the [Open Source License].
 * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *
 * See the [Open Source License] for more details.
 *
 * Author: Qing'ao Zhang
 * Created: Mar. 27, 2023
 * Supported by: National Key Research and Development Program of China
 */

import { Disposable } from "@/common/disposable"
import { commandManager } from "@/common/cmd/manager"
import { ipcRenderer } from "electron"

export const materialLibraryManager = new class MaterialLibraryManager extends Disposable {
    constructor() {
        super()
        return
    }

    public activate() {
        commandManager.registerCommand("materialLibrary.open", this.open)
        commandManager.registerCommand("materialLibrary.close", this.close)
        commandManager.registerCommand("materialLibrary.openAdd", this.openAdd)
        commandManager.registerCommand("materialLibrary.closeAdd", this.closeAdd)
        commandManager.registerCommand("materialLibrary.editMaterial", this.editMaterial)
        commandManager.registerCommand("materialLibrary.editMaterialProperty", this.editMaterialProperty)
        commandManager.registerCommand("materialLibrary.deleteMaterial", this.deleteMaterial)
        commandManager.registerCommand("materialLibrary.deleteMaterialProperty", this.deleteMaterialProperty)
        commandManager.registerCommand("materialLibrary.save", this.save)
        commandManager.registerCommand("materialLibrary.importMaterials", this.importMaterials)
        commandManager.registerCommand("materialLibrary.exportMaterials", this.exportMaterials)
        return
    }

    public async open() {
        console.log("open material library window")
        ipcRenderer.send('control', 'new-win', 'MaterialLibrary')
        return
    }

    public async close() {
        console.log("close material library window")
        ipcRenderer.send('child-MaterialLibrary', 'close')
        return
    }

    public async openAdd() {
        console.log("Open the add material window")
        ipcRenderer.send('control', 'new-win', 'AddMaterial')
        return
    }

    public async closeAdd() {
        console.log("close material library window")
        ipcRenderer.send('child-AddMaterial', 'close')
        return
    }

    public async editMaterial() {
        console.log("edit material")
        return
    }

    public async editMaterialProperty() {
        console.log("edit material property")
        return
    }

    public async deleteMaterial() {
        console.log("delete material")
        return
    }

    public async deleteMaterialProperty() {
        console.log("delete material property")
        return
    }

    public async save() {
        console.log("save material library")
        return
    }

    public async importMaterials() {
        console.log("Import materials from a file.")
        return
    }

    public async exportMaterials() {
        console.log("Export materials to a file.")
        return
    }
}